﻿<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>详情页</title>
    <script src="js/axios.min.js"></script>
    <link rel="stylesheet" href="css/reset.css" />
    <link rel="stylesheet" href="css/iconfont.css" />
    <link rel="stylesheet" href="css/xiangqiingye.css" />
  </head>
  <body>
    <div class="header">
      <div class="wrap">
        <ul class="header-left">
          <li><a href="#">小米商城</a><span>|</span></li>
          <li><a href="#">MIUI</a><span>|</span></li>
          <li><a href="#">loT</a><span>|</span></li>
          <li><a href="#">云服务</a><span>|</span></li>
          <li><a href="#">天星数科</a><span>|</span></li>
          <li><a href="#">有品</a><span>|</span></li>
          <li><a href="#">小爱开放平台</a><span>|</span></li>
          <li><a href="#">企业团购</a><span>|</span></li>
          <li><a href="#">资质证照</a><span>|</span></li>
          <li><a href="#">协议规则</a><span>|</span></li>
          <li>
            <a href="#">下载app</a><span>|</span>
            <div class="download">
              <a href="#">
                <img src="images/78c30d4f259ed43ab20e810a522a6249.png" alt="" />
                <p>小米商城APP</p>
              </a>
            </div>
            <div class="triangle"></div>
          </li>
          <li><a href="#">智能生活</a><span>|</span></li>
          <li><a href="#">Select Location</a></li>
        </ul>
        <ul class="header-right">
          <li><a href="./denglu.html">登录</a><span>|</span></li>
          <li><a href="./zhuce.html">注册</a><span>|</span></li>
          <li><a href="#">消息通知</a></li>
          <li class="cart">
            <a href="#">
              <i class="iconfont">&#xe653;</i>
              购物车(0)
            </a>
            <div class="cart-list">购物车中还没有商品，赶紧选购吧！</div>
          </li>
        </ul>
      </div>
    </div>
    <!-- 导航开始 -->
    <div class="nav">
      <div class="wrap">
        <div class="logo">
          <a href="index.html">
            <img src="images/logo-mi2.png" alt="" />
          </a>
        </div>
        <div class="nav-bar">
          <ul>
            <li>
              <a href="#">小米手机</a>
              <div class="nav-bar-list">
                <div class="wrap">
                  <ul>
                    <li>
                      <a href="#">
                        <div class="img-box">
                          <img
                            src="images/a1c45eadcedeb27b1cafca0359422da9.webp"
                            alt=""
                          />
                        </div>
                        <p class="name1">小米11 Pro</p>
                        <p class="price1">4499元起</p>
                      </a>
                    </li>
                    <li>
                      <a href="#">
                        <div class="img-box">
                          <img
                            src="images/a1c45eadcedeb27b1cafca0359422da9.webp"
                            alt=""
                          />
                        </div>
                        <p class="name1">小米11 Pro</p>
                        <p class="price1">4499元起</p>
                      </a>
                    </li>
                    <li>
                      <a href="#">
                        <div class="img-box">
                          <img
                            src="images/a1c45eadcedeb27b1cafca0359422da9.webp"
                            alt=""
                          />
                        </div>
                        <p class="name1">小米11 Pro</p>
                        <p class="price1">4499元起</p>
                      </a>
                    </li>
                    <li>
                      <a href="#">
                        <div class="img-box">
                          <img
                            src="images/a1c45eadcedeb27b1cafca0359422da9.webp"
                            alt=""
                          />
                        </div>
                        <p class="name1">小米11 Pro</p>
                        <p class="price1">4499元起</p>
                      </a>
                    </li>
                    <li>
                      <a href="#">
                        <div class="img-box">
                          <img
                            src="images/a1c45eadcedeb27b1cafca0359422da9.webp"
                            alt=""
                          />
                        </div>
                        <p class="name1">小米11 Pro</p>
                        <p class="price1">4499元起</p>
                      </a>
                    </li>
                    <li>
                      <a href="#">
                        <div class="img-box">
                          <img
                            src="images/a1c45eadcedeb27b1cafca0359422da9.webp"
                            alt=""
                          />
                        </div>
                        <p class="name1">小米11 Pro</p>
                        <p class="price1">4499元起</p>
                      </a>
                    </li>
                  </ul>
                </div>
              </div>
            </li>
            <li>
              <a href="#">Redmi红米</a>
              <div class="nav-bar-list">
                <div class="wrap">
                  <ul>
                    <li>
                      <a href="#">
                        <div class="img-box">
                          <img
                            src="images/88bb84ff06f0ab467b859aeed36b817a.webp"
                            alt=""
                          />
                        </div>
                        <p class="name1">小米11 Pro</p>
                        <p class="price1">4499元起</p>
                      </a>
                    </li>
                    <li>
                      <a href="#">
                        <div class="img-box">
                          <img
                            src="images/a1c45eadcedeb27b1cafca0359422da9.webp"
                            alt=""
                          />
                        </div>
                        <p class="name1">小米11 Pro</p>
                        <p class="price1">4499元起</p>
                      </a>
                    </li>
                    <li>
                      <a href="#">
                        <div class="img-box">
                          <img
                            src="images/a1c45eadcedeb27b1cafca0359422da9.webp"
                            alt=""
                          />
                        </div>
                        <p class="name1">小米11 Pro</p>
                        <p class="price1">4499元起</p>
                      </a>
                    </li>
                    <li>
                      <a href="#">
                        <div class="img-box">
                          <img
                            src="images/a1c45eadcedeb27b1cafca0359422da9.webp"
                            alt=""
                          />
                        </div>
                        <p class="name1">小米11 Pro</p>
                        <p class="price1">4499元起</p>
                      </a>
                    </li>
                    <li>
                      <a href="#">
                        <div class="img-box">
                          <img
                            src="images/a1c45eadcedeb27b1cafca0359422da9.webp"
                            alt=""
                          />
                        </div>
                        <p class="name1">小米11 Pro</p>
                        <p class="price1">4499元起</p>
                      </a>
                    </li>
                    <li>
                      <a href="#">
                        <div class="img-box">
                          <img
                            src="images/a1c45eadcedeb27b1cafca0359422da9.webp"
                            alt=""
                          />
                        </div>
                        <p class="name1">小米11 Pro</p>
                        <p class="price1">4499元起</p>
                      </a>
                    </li>
                  </ul>
                </div>
              </div>
            </li>
            <li><a href="#">电视</a></li>
            <li><a href="#">笔记本</a></li>
            <li><a href="#">家电</a></li>
            <li><a href="#">路由器</a></li>
            <li><a href="#">智能硬件</a></li>
            <li><a href="#">服务</a></li>
            <li><a href="#">社区</a></li>
          </ul>
        </div>
        <div class="search">
          <input type="text" />
          <a href="#" class="iconfont">&#xe63d;</a>
          <div class="search-list">
            <a href="#">全部商品</a>
            <a href="#">全部商品</a>
            <a href="#">全部商品</a>
            <a href="#">全部商品</a>
            <a href="#">全部商品</a>
            <a href="#">全部商品</a>
            <a href="#">全部商品</a>
            <a href="#">全部商品</a>
          </div>
        </div>
      </div>
    </div>
    <!-- 导航结束 -->
    <div class="dabox">
      <div class="tu"><img src="" alt="" /></div>
      <div class="box-right">
        <input type="number" c="" id="" />
      </div>
    </div>
    <div class="footer">
      <div class="site-footer">
        <div class="wrap">
          <div class="footer-service">
            <ul>
              <li>
                <a href="#">
                  <i class="iconfont">&#xe606;</i>
                  <span>15天免费换货</span>
                </a>
              </li>
              <li>
                <a href="#">
                  <i class="iconfont">&#xe606;</i>
                  <span>15天免费换货</span>
                </a>
              </li>
              <li>
                <a href="#">
                  <i class="iconfont">&#xe606;</i>
                  <span>15天免费换货</span>
                </a>
              </li>
              <li>
                <a href="#">
                  <i class="iconfont">&#xe606;</i>
                  <span>15天免费换货</span>
                </a>
              </li>
              <li>
                <a href="#">
                  <i class="iconfont">&#xe606;</i>
                  <span>15天免费换货</span>
                </a>
              </li>
            </ul>
          </div>
          <div class="footer-links">
            <ul>
              <li>帮助中心</li>
              <li>
                <a href="#">账户管理</a>
              </li>
              <li>
                <a href="#">账户管理</a>
              </li>
              <li>
                <a href="#">账户管理</a>
              </li>
            </ul>
            <ul>
              <li>帮助中心</li>
              <li>
                <a href="#">账户管理</a>
              </li>
              <li>
                <a href="#">账户管理</a>
              </li>
              <li>
                <a href="#">账户管理</a>
              </li>
            </ul>
            <ul>
              <li>帮助中心</li>
              <li>
                <a href="#">账户管理</a>
              </li>
              <li>
                <a href="#">账户管理</a>
              </li>
              <li>
                <a href="#">账户管理</a>
              </li>
            </ul>
            <ul>
              <li>帮助中心</li>
              <li>
                <a href="#">账户管理</a>
              </li>
              <li>
                <a href="#">账户管理</a>
              </li>
              <li>
                <a href="#">账户管理</a>
              </li>
            </ul>
            <ul>
              <li>帮助中心</li>
              <li>
                <a href="#">账户管理</a>
              </li>
              <li>
                <a href="#">账户管理</a>
              </li>
              <li>
                <a href="#">账户管理</a>
              </li>
            </ul>
            <ul>
              <li>帮助中心</li>
              <li>
                <a href="#">账户管理</a>
              </li>
              <li>
                <a href="#">账户管理</a>
              </li>
              <li>
                <a href="#">账户管理</a>
              </li>
            </ul>
            <div class="contact">
              <p class="tel">400-100-5678</p>
              <p class="time">8:00-18:00（仅收市话费）</p>
              <a href="#" class="kefu">
                <i class="iconfont">&#xe710;</i>
                人工客服
              </a>
              <p class="follow">
                关注小米：
                <span class="wb"></span>
                <span class="wx"></span>
                <img src="images/wx-img.png" alt="" class="wx-img" />
              </p>
            </div>
          </div>
        </div>
      </div>
      <div class="site-info">
        <div class="wrap">
          <div class="footer-logo">
            <img src="images/logo-mi2.png" alt="" />
          </div>
          <div class="sites">
            <p>
              <a rel="nofollow" href="//www.mi.com/index.html" target="_blank"
                >小米商城</a
              >
              <span class="sep">|</span>
              <a rel="nofollow" href="//www.miui.com/" target="_blank">MIUI</a>
              <span class="sep">|</span>
              <a rel="nofollow" href="//home.mi.com/index.html" target="_blank"
                >米家</a
              >
              <span class="sep">|</span>
              <a rel="nofollow" href="http://www.miliao.com/" target="_blank"
                >米聊</a
              >
              <span class="sep">|</span>
              <a rel="nofollow" href="//www.duokan.com/" target="_blank"
                >多看</a
              >
              <span class="sep">|</span>
              <a rel="nofollow" href="//game.xiaomi.com/" target="_blank"
                >游戏</a
              >
              <span class="sep">|</span>
              <a
                rel="nofollow"
                href="//b.mi.com/?client_id=180100031058&masid=17409.0358"
                target="_blank"
                >政企服务</a
              >
              <span class="sep">|</span>
              <a rel="nofollow" href="//xiaomi.tmall.com/" target="_blank"
                >小米天猫店</a
              >
              <span class="sep">|</span>
              <a
                rel="nofollow"
                href="//privacy.mi.com/all/zh_CN/"
                target="_blank"
                >小米集团隐私政策</a
              >
              <span class="sep">|</span>
              <a
                rel="nofollow"
                href="//cdn.cnbj1.fds.api.mi-img.com/mi-mall/f516fe9e2c01.html"
                target="_blank"
                >小米公司儿童信息保护规则</a
              >
              <span class="sep">|</span>
              <a
                rel="nofollow"
                href="//cdn.cnbj1.fds.api.mi-img.com/mi-mall/ded8d0e4a77d.html"
                target="_blank"
                >小米商城隐私政策</a
              >
              <span class="sep">|</span>
              <a
                rel="nofollow"
                href="//www.mi.com/about/user-agreement/"
                target="_blank"
                >小米商城用户协议</a
              >
              <span class="sep">|</span>
              <a rel="nofollow" href="//static.mi.com/feedback/" target="_blank"
                >问题反馈</a
              >
              <span class="sep">|</span>
              <a
                rel="nofollow"
                href="javascript:void(0);"
                class="J_siteGlobalRegion"
                >Select Location</a
              >
              <br />
              <a rel="nofollow" href="http://www.mi.com/beihu" target="_blank"
                >北京互联网法院法律服务工作站</a
              >
              <span class="sep">|</span>
              <a rel="nofollow" href="http://www.cca.org.cn/" target="_blank"
                >中国消费者协会</a
              >
              <span class="sep">|</span>
              <a rel="nofollow" href="http://www.bj315.org/" target="_blank"
                >北京市消费者协会</a
              >
            </p>
            <p>
              ©
              <a href="javascript:;" target="_blank" title="mi.com">mi.com</a>
              京ICP证110507号
              <a href="http://beian.miit.gov.cn/" target="_blank" rel="nofollow"
                >京ICP备10046444号</a
              >
              <a
                rel="nofollow"
                href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=11010802020134"
                target="_blank"
                >京公网安备11010802020134号</a
              >
              <a href="//www.mi.com/culture-license/" target="_blank"
                >京网文[2020]0276-042号</a
              >
              <br />
              <a href="//www.mi.com/medical/record/" target="_blank"
                >（京）网械平台备字（2018）第00005号</a
              >
              <a href="//www.mi.com/medical/qualification/" target="_blank"
                >互联网药品信息服务资格证 (京)-非经营性-2014-0090</a
              >
              <a href="//www.mi.com/business-license/" target="_blank"
                >营业执照</a
              >
              <a href="//www.mi.com/medical/list/" target="_blank"
                >医疗器械质量公告</a
              >
              <br />
              <a
                href="https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/e0c7d4cf3b7cd88de10196e30c92e020.png"
                target="_blank"
                >增值电信业务许可证</a
              >&nbsp;网络食品经营备案 京食药网食备202010048 &nbsp;
              <a
                href="https://cdn.cnbj1.fds.api.mi-img.com/mi-mall/c6859168166651511897f54fa1047fe3.png"
                target="_blank"
                >食品经营许可证</a
              >
              <br />
              违法和不良信息举报电话：171-5104-4404&nbsp;<a
                href="https://www.mi.com/intellectual"
                target="_blank"
                >知识产权侵权投诉</a
              >&nbsp;本网站所列数据，除特殊说明，所有数据均出自我司实验室测试
            </p>
            <p>
              <img src="images/truste.png" alt="" />
              <img src="images/truste.png" alt="" />
              <img src="images/truste.png" alt="" />
              <img src="images/truste.png" alt="" />
              <img src="images/truste.png" alt="" />
            </p>
          </div>
          <img src="images/slogan2020.png" alt="" class="slogan" />
        </div>
      </div>
    </div>
    <div class="home">
      <a class="kj" href="#">
        <div class="iconfont">&#xe622;</div>
        <span>手机APP</span>
        <div class="yc">
          <img src="images/wx-img.png" alt="" />
          <span>扫码领取新人百元礼包</span>
        </div>
      </a>
      <a class="kj" href="">
        <div class="iconfont">&#xe615;</div>
        <span>个人中心</span>
      </a>
      <a class="kj" href="">
        <div class="iconfont">&#xe6ab;</div>
        <span>人工客服</span>
      </a>
      <a class="kj" onclick="toMyCart()">
        <div class="iconfont">&#xe653;</div>
        <span>购物车</span>
      </a>
      <a class="db kj" href="#">
        <div class="iconfont">&#xe666;</div>
        <span>返回顶部</span>
      </a>
    </div>
    <script src="js/jquery-1.11.0.min.js"></script>
    <script>
      let a = new URLSearchParams(location.search);
      console.log(a);
      let ul = document.querySelector(".dabox");
      let tanchu = document.querySelector(".tanchu");
      let id = a.get("pid");
      console.log(id);
      let b = "http://jx.xuzhixiang.top/ap/api/detail.php";
      axios.get(b, { params: { id } }).then((r) => {
        let html = "";
        console.log(r);
        html += `
            <div class="tu"><img src="${r.data.data.pimg}" ></div>
          <div class="box-right">
            <h2>${r.data.data.pname}</h2>
            <p>
              299米金兑换10元优惠券；699米金兑换30元优惠券；碎屏保，
              延保5折；光大信用卡分期支付满1000减80元
              </p>
              <p>小米自营</p>
              <p><span>￥</span>${r.data.data.pprice}</p>
              <p>
              <input class="b_r_num" type="number" value="1" />
              <button class="tanchu" onclick="addCard()"><a>加入购物车</a></button>
              <button class="b_r_love">喜欢</button>
            </p>
              <p>
              <span><a href="">小米自营</a></span>  <span><a href="">小米发货</a></span>  <span><a href="">7天无理由退货</a></span>  <span><a href="">运费说明</a></span>  <span><a href="">企业信息</a></span>  <span><a href="">7天价格保护</a></span>
              </p>

            </div>
            `;
        ul.innerHTML = html;
      });
      $(document).ready(function () {
        $(window).scroll(function () {
          $(".db").css({ display: "none" });
          if ($(window).scrollTop() > 300) {
            $(".db").css({ display: "block" });
          } else {
            $(".db").css({ display: "none" });
          }
        });
      });

      /* 添加商品 接口

          接口地址：  http://jx.xuzhixiang.top/ap/api/goods/goods-add.php
               接口请求方式：get
               接口参数：
              1.pimg
              2.pname
              3.pprice
              4.pdesc
              5.uid （可选）用户商品
      使用方式  post 请求，参数在请求体 */
      async function addCard() {
        let uid = localStorage.getItem("id");
        let pid = id;
        localStorage.setItem("pid", id);
        console.log(id);
        let ipt = document.querySelector(".b_r_num");
        let pnum = ipt.value;
        let params = { uid, pid, pnum };
        console.log(params); // {Uid: '74911', id: '645579', pnum: '1'}
        let addCartAPI = "http://jx.xuzhixiang.top/ap/api/add-product.php";
        let res = await axios.get(addCartAPI, { params: params });
        console.log(params); // {Uid: '74911', id: '645579', pnum: '1'}
        console.log(res.data);
        alert("加入购物车成功");
      }
      /* 给用户购物车中添加商品 接口
      接口地址：http://jx.xuzhixiang.top/ap/api/add-product.php
           接口请求方式：get
           接口参数：
                uid  用户id
                pid  商品id
                pnum  要添加的商品数量使用方式
      http://jx.xuzhixiang.top/ap/api/add-product.php?uid=1&pid=1&pnum=1
                服务器返回json数据 */
      function toMyCart() {
        let uid = localStorage.getItem("id");
        console.log(uid);
        if (uid) {
          location.href = "gouwuche.html";
        } else {
          location.href = "denglu.html";
        }
      }
    </script>
  </body>
</html>
